home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / VBASIC / T2W32307.ZIP / _MISC.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-09-07  |  17.3 KB  |  493 lines

  1. VERSION 4.00
  2. Begin VB.Form frmMisc 
  3.    BorderStyle     =   4  'Fixed ToolWindow
  4.    Caption         =   "Miscelleanous"
  5.    ClientHeight    =   4785
  6.    ClientLeft      =   1890
  7.    ClientTop       =   3270
  8.    ClientWidth     =   7485
  9.    Height          =   5190
  10.    Left            =   1830
  11.    MaxButton       =   0   'False
  12.    MDIChild        =   -1  'True
  13.    ScaleHeight     =   4785
  14.    ScaleWidth      =   7485
  15.    ShowInTaskbar   =   0   'False
  16.    Top             =   2925
  17.    Width           =   7605
  18.    Begin VB.TextBox txt_Result 
  19.       BackColor       =   &H00C0C0C0&
  20.       BorderStyle     =   0  'None
  21.       Height          =   4005
  22.       Left            =   105
  23.       Locked          =   -1  'True
  24.       MultiLine       =   -1  'True
  25.       ScrollBars      =   2  'Vertical
  26.       TabIndex        =   0
  27.       Top             =   630
  28.       Width           =   7260
  29.    End
  30.    Begin Threed.SSPanel SSPanel1 
  31.       Align           =   1  'Align Top
  32.       Height          =   480
  33.       Left            =   0
  34.       TabIndex        =   1
  35.       Top             =   0
  36.       Width           =   7485
  37.       _Version        =   65536
  38.       _ExtentX        =   13203
  39.       _ExtentY        =   847
  40.       _StockProps     =   15
  41.       ForeColor       =   -2147483640
  42.       BackColor       =   12632256
  43.       Begin VB.ComboBox cmb_Function 
  44.          Height          =   315
  45.          Left            =   1365
  46.          TabIndex        =   2
  47.          Top             =   90
  48.          Width           =   4785
  49.       End
  50.       Begin Threed.SSCommand SSCommand1 
  51.          Default         =   -1  'True
  52.          Height          =   300
  53.          Left            =   6615
  54.          TabIndex        =   6
  55.          Top             =   90
  56.          Width           =   465
  57.          _Version        =   65536
  58.          _ExtentX        =   820
  59.          _ExtentY        =   529
  60.          _StockProps     =   78
  61.          Caption         =   "&Go"
  62.          BevelWidth      =   1
  63.          RoundedCorners  =   0   'False
  64.          Outline         =   0   'False
  65.       End
  66.       Begin VB.Label Label2 
  67.          Caption         =   "&Select a function"
  68.          Height          =   255
  69.          Left            =   90
  70.          TabIndex        =   5
  71.          Top             =   120
  72.          Width           =   1275
  73.       End
  74.       Begin Threed.SSCommand cmdNP 
  75.          Height          =   300
  76.          Index           =   0
  77.          Left            =   6300
  78.          TabIndex        =   4
  79.          Top             =   90
  80.          Width           =   255
  81.          _Version        =   65536
  82.          _ExtentX        =   450
  83.          _ExtentY        =   529
  84.          _StockProps     =   78
  85.          Caption         =   "<"
  86.          BevelWidth      =   1
  87.          Font3D          =   3
  88.          RoundedCorners  =   0   'False
  89.          Outline         =   0   'False
  90.       End
  91.       Begin Threed.SSCommand cmdNP 
  92.          Height          =   300
  93.          Index           =   1
  94.          Left            =   7140
  95.          TabIndex        =   3
  96.          Top             =   90
  97.          Width           =   255
  98.          _Version        =   65536
  99.          _ExtentX        =   450
  100.          _ExtentY        =   529
  101.          _StockProps     =   78
  102.          Caption         =   ">"
  103.          BevelWidth      =   1
  104.          Font3D          =   3
  105.          RoundedCorners  =   0   'False
  106.          Outline         =   0   'False
  107.       End
  108.    End
  109. Attribute VB_Name = "frmMisc"
  110. Attribute VB_Creatable = False
  111. Attribute VB_Exposed = False
  112. Option Explicit
  113. Option Base 1
  114. Private Const Iteration = 250
  115. Dim IsLoaded         As Integer
  116. Dim TimerStartOk     As Integer
  117. Dim TimerCloseOk     As Integer
  118. Dim TimerHandle      As Integer
  119. Dim TimerValue       As Long
  120. Private Sub cmdNP_Click(Index As Integer)
  121.    Call sub_NextPrev(cmb_Function, Index)
  122. End Sub
  123. Private Sub cmb_Function_Click()
  124.    If (IsLoaded = False) Then Exit Sub
  125.    Call cDisableFI(mdiT2W.Picture1)
  126.    txt_Result = ""
  127.    DoEvents
  128.    Select Case cmb_Function.ListIndex
  129.       Case 0
  130.          Call TestSwapX
  131.       Case 1
  132.          Call TestMinMax
  133.       Case 2
  134.          Call TestIncrX
  135.       Case 3
  136.          Call TestRndX
  137.       Case 4
  138.          Call TestSpellMoney
  139.       Case 5
  140.          Call TestFraction
  141.       Case 6
  142.          Call TestBaseConversion
  143.       Case 7
  144.          Call TestCombination
  145.    End Select
  146.    DoEvents
  147.    Call cEnableFI(mdiT2W.Picture1)
  148. End Sub
  149. Private Sub Form_Activate()
  150.    mdiT2W.Label2.Caption = cInsertBlocks(mdiT2W.Label2.Tag, "" & Iteration)
  151. End Sub
  152. Private Sub Form_Load()
  153.    IsLoaded = False
  154.    Show
  155.    Call sub_Load_Combo(cmb_Function, T2WDirInst + "_misc.t2w")
  156.    IsLoaded = True
  157. End Sub
  158. Private Sub SSCommand1_Click()
  159.    Call cmb_Function_Click
  160. End Sub
  161. Private Sub TestSwapX()
  162.    Dim intResult        As Integer
  163.    Dim strResult        As String
  164.    Dim strDisplay       As String
  165.    Dim i                As Integer
  166.    Dim Str1             As String
  167.    Dim Str2             As String
  168.    Dim b1               As Byte
  169.    Dim b2               As Byte
  170.    Dim i1               As Integer
  171.    Dim i2               As Integer
  172.    Dim l1               As Long
  173.    Dim l2               As Long
  174.    Dim s1               As Single
  175.    Dim s2               As Single
  176.    Dim d1               As Double
  177.    Dim d2               As Double
  178.    strResult = ""
  179.    strDisplay = ""
  180.    Str1 = "Hello"
  181.    Str2 = "World"
  182.    b1 = 0
  183.    b2 = 255
  184.    i1 = -32768
  185.    i2 = 32767
  186.    l1 = -2147483647
  187.    l2 = 2147483647
  188.    s1 = 12345.5678
  189.    s2 = 98765.4321
  190.    d1 = 12345.67890123
  191.    d2 = 98765.43210987
  192.    strDisplay = strDisplay + "SwapB of '" & b1 & " - " & b2 & "' is "
  193.    Call cSwapB(b1, b2)
  194.    strDisplay = strDisplay + "'" & b1 & " - " & b2 & "'" & vbCrLf & vbCrLf
  195.    strDisplay = strDisplay + "SwapI of '" & i1 & " - " & i2 & "' is "
  196.    Call cSwapI(i1, i2)
  197.    strDisplay = strDisplay + "'" & i1 & " - " & i2 & "'" & vbCrLf & vbCrLf
  198.    strDisplay = strDisplay + "SwapL of '" & l1 & " - " & l2 & "' is "
  199.    Call cSwapL(l1, l2)
  200.    strDisplay = strDisplay + "'" & l1 & " - " & l2 & "'" & vbCrLf & vbCrLf
  201.    strDisplay = strDisplay + "SwapS of '" & s1 & " - " & s2 & "' is "
  202.    Call cSwapS(s1, s2)
  203.    strDisplay = strDisplay + "'" & s1 & " - " & s2 & "'" & vbCrLf & vbCrLf
  204.    strDisplay = strDisplay + "SwapD of '" & d1 & " - " & d2 & "' is "
  205.    Call cSwapD(d1, d2)
  206.    strDisplay = strDisplay + "'" & d1 & " - " & d2 & "'" & vbCrLf & vbCrLf
  207.    strDisplay = strDisplay + "SwapStr of '" & Str1 & " - " & Str2 & "' is "
  208.    Call cSwapStr(Str1, Str2)
  209.    strDisplay = strDisplay + "'" & Str1 & " - " & Str2 & "'" & vbCrLf & vbCrLf
  210.    strDisplay = strDisplay + "SwapStr of '" & Str1 & " - " & Str2 & "' is "
  211.    Call cSwapStr(Str1, Str2)
  212.    strDisplay = strDisplay + "'" & Str1 & " - " & Str2 & "'"
  213.      
  214.    txt_Result = strDisplay
  215.    'time the function
  216.    TimerHandle = cTimerOpen()
  217.    TimerStartOk = cTimerStart(TimerHandle)
  218.    For i = 1 To Iteration
  219.       Call cSwapD(d1, d2)
  220.    Next i
  221.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  222.    TimerCloseOk = cTimerClose(TimerHandle)
  223. End Sub
  224. Private Sub TestMinMax()
  225.    Dim lngResult        As Long
  226.    Dim strResult        As String
  227.    Dim strDisplay       As String
  228.    Dim i                As Integer
  229.    Dim Str1             As String
  230.    Dim Str2             As String
  231.    lngResult = 0
  232.    strResult = ""
  233.    strDisplay = ""
  234.      
  235.    strDisplay = strDisplay & "Min of '32760,1234567' is '" & cMin(32760, 1234567) & "'" & vbCrLf & vbCrLf
  236.    strDisplay = strDisplay & "Max of '32760,1234567' is '" & cMax(32760, 1234567) & "'"
  237.    txt_Result = strDisplay
  238.    'time the function
  239.    TimerHandle = cTimerOpen()
  240.    TimerStartOk = cTimerStart(TimerHandle)
  241.    For i = 1 To Iteration
  242.       lngResult = cMax(32760, 1234567)
  243.    Next i
  244.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  245.    TimerCloseOk = cTimerClose(TimerHandle)
  246. End Sub
  247. Private Sub TestIncrX()
  248.    Dim lngResult        As Long
  249.    Dim strResult        As String
  250.    Dim strDisplay       As String
  251.    Dim i                As Integer
  252.    Dim Str1             As String
  253.    Dim Str2             As String
  254.    lngResult = 0
  255.    strResult = ""
  256.    strDisplay = ""
  257.      
  258.    i = 1
  259.    Call cIncrI(i)
  260.    strDisplay = strDisplay & "IncrI of '" & 1 & "' is '" & i & "'" & vbCrLf
  261.    i = 32000
  262.    Call cIncrI(i)
  263.    strDisplay = strDisplay & "IncrI of '" & 32000 & "' is '" & i & "'" & vbCrLf
  264.    i = -32768
  265.    Call cIncrI(i)
  266.    strDisplay = strDisplay & "IncrI of '" & -32768 & "' is '" & i & "'" & vbCrLf & vbCrLf
  267.    i = 1
  268.    Call cDecrI(i)
  269.    strDisplay = strDisplay & "DecrI of '" & 1 & "' is '" & i & "'" & vbCrLf
  270.    i = 32000
  271.    Call cDecrI(i)
  272.    strDisplay = strDisplay & "DecrI of '" & 32000 & "' is '" & i & "'" & vbCrLf
  273.    i = -32767
  274.    Call cDecrI(i)
  275.    strDisplay = strDisplay & "DecrI of '" & -32767 & "' is '" & i & "'" & vbCrLf & vbCrLf
  276.    lngResult = 1
  277.    Call cIncrL(lngResult)
  278.    strDisplay = strDisplay & "IncrL of '" & 1 & "' is '" & lngResult & "'" & vbCrLf
  279.    lngResult = 32000
  280.    Call cIncrL(lngResult)
  281.    strDisplay = strDisplay & "IncrL of '" & 32000 & "' is '" & lngResult & "'" & vbCrLf
  282.    lngResult = -32768
  283.    Call cIncrL(lngResult)
  284.    strDisplay = strDisplay & "IncrL of '" & -32768 & "' is '" & lngResult & "'" & vbCrLf & vbCrLf
  285.    lngResult = 1
  286.    Call cDecrL(lngResult)
  287.    strDisplay = strDisplay & "DecrL of '" & 1 & "' is '" & lngResult & "'" & vbCrLf
  288.    lngResult = 32000
  289.    Call cDecrL(lngResult)
  290.    strDisplay = strDisplay & "DecrL of '" & 32000 & "' is '" & lngResult & "'" & vbCrLf
  291.    lngResult = -32768
  292.    Call cDecrL(lngResult)
  293.    strDisplay = strDisplay & "DecrL of '" & -32768 & "' is '" & lngResult & "'"
  294.    txt_Result = strDisplay
  295.    'time the function
  296.    TimerHandle = cTimerOpen()
  297.    TimerStartOk = cTimerStart(TimerHandle)
  298.    For i = 1 To Iteration
  299.       Call cIncrI(i)
  300.    Next i
  301.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  302.    TimerCloseOk = cTimerClose(TimerHandle)
  303. End Sub
  304. Private Sub TestRndX()
  305.    Dim lngResult        As Long
  306.    Dim strResult        As String
  307.    Dim strDisplay       As String
  308.    Dim i                As Integer
  309.    Dim Str1             As String
  310.    Dim Str2             As String
  311.    lngResult = 0
  312.    strResult = ""
  313.    strDisplay = ""
  314.      
  315.    Call cRndInit(-1)
  316.    strDisplay = "Some random Integer number" & vbCrLf & vbCrLf
  317.    For i = 1 To 2
  318.       strDisplay = strDisplay & cRndI() & vbCrLf
  319.    Next i
  320.    strDisplay = strDisplay & vbCrLf
  321.    strDisplay = strDisplay & "Some random Long number" & vbCrLf & vbCrLf
  322.    For i = 1 To 2
  323.       strDisplay = strDisplay & cRndL() & vbCrLf
  324.    Next i
  325.    strDisplay = strDisplay & vbCrLf
  326.    strDisplay = strDisplay & "Some random Single number" & vbCrLf & vbCrLf
  327.    For i = 1 To 2
  328.       strDisplay = strDisplay & cRndS() & vbCrLf
  329.    Next i
  330.    strDisplay = strDisplay & vbCrLf
  331.    strDisplay = strDisplay & "Some random Double number" & vbCrLf & vbCrLf
  332.    For i = 1 To 2
  333.       strDisplay = strDisplay & cRndD() & vbCrLf
  334.    Next i
  335.    strDisplay = strDisplay & vbCrLf
  336.    strDisplay = strDisplay & "Some random Double number between 0.0 and 1.0" & vbCrLf & vbCrLf
  337.    For i = 1 To 2
  338.       strDisplay = strDisplay & cRnd() & vbCrLf
  339.    Next i
  340.    txt_Result = strDisplay
  341.    'time the function
  342.    TimerHandle = cTimerOpen()
  343.    TimerStartOk = cTimerStart(TimerHandle)
  344.    For i = 1 To Iteration
  345.       lngResult = cRndL()
  346.    Next i
  347.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  348.    TimerCloseOk = cTimerClose(TimerHandle)
  349. End Sub
  350. Private Sub TestSpellMoney()
  351.    Dim lngResult        As Long
  352.    Dim strResult        As String
  353.    Dim strDisplay       As String
  354.    Dim i                As Integer
  355.    Dim Str1             As String
  356.    Dim Units            As String
  357.    Dim Cents            As String
  358.    lngResult = 0
  359.    strResult = ""
  360.    strDisplay = ""
  361.      
  362.    Units = "dollars"
  363.    Cents = "cents"
  364.    strDisplay = "Spelling the following money value " & vbCrLf & vbCrLf
  365.    strDisplay = strDisplay & "4.12 is '" & cSpellMoney(4.12, Units, Cents) & "'" & vbCrLf & vbCrLf
  366.    strDisplay = strDisplay & "16 is '" & cSpellMoney(16, Units, Cents) & "'" & vbCrLf & vbCrLf
  367.    strDisplay = strDisplay & "25 is '" & cSpellMoney(25, Units, Cents) & "'" & vbCrLf & vbCrLf
  368.    strDisplay = strDisplay & "34 is '" & cSpellMoney(34, Units, Cents) & "'" & vbCrLf & vbCrLf
  369.    strDisplay = strDisplay & "43 is '" & cSpellMoney(43, Units, Cents) & "'" & vbCrLf & vbCrLf
  370.    strDisplay = strDisplay & "61 is '" & cSpellMoney(61, Units, Cents) & "'" & vbCrLf & vbCrLf
  371.    strDisplay = strDisplay & "98765.43 is '" & cSpellMoney(98765.43, Units, Cents) & "'" & vbCrLf & vbCrLf
  372.    strDisplay = strDisplay & "123456789.75 is '" & cSpellMoney(123456789.75, Units, Cents) & "'"
  373.    txt_Result = strDisplay
  374.    'time the function
  375.    TimerHandle = cTimerOpen()
  376.    TimerStartOk = cTimerStart(TimerHandle)
  377.    For i = 1 To Iteration
  378.       strResult = cSpellMoney(12.34, Units, Cents)
  379.    Next i
  380.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  381.    TimerCloseOk = cTimerClose(TimerHandle)
  382. End Sub
  383. Private Sub TestFraction()
  384.    Dim dblResult        As Double
  385.    Dim strResult        As String
  386.    Dim strDisplay       As String
  387.    Dim i                As Integer
  388.    Dim v                As Double
  389.    Dim n                As Double
  390.    Dim p                As Double
  391.    Dim q                As Double
  392.    Dim e                As Integer
  393.    Dim Str1             As String
  394.    Dim Units            As String
  395.    Dim Cents            As String
  396.    dblResult = 0
  397.    strResult = ""
  398.    strDisplay = ""
  399.      
  400.    strDisplay = "Determining fraction part (numerator/denominator) for the following value " & vbCrLf & vbCrLf
  401.    n = 4.12
  402.    v = cFraction(n, p, q)
  403.    strDisplay = strDisplay & n & " is " & p & " / " & q & vbCrLf
  404.    strDisplay = strDisplay & "   value is " & v & vbCrLf & vbCrLf
  405.    n = 1.75
  406.    v = cFraction(n, p, q)
  407.    strDisplay = strDisplay & n & " is " & p & " / " & q & vbCrLf
  408.    strDisplay = strDisplay & "   value is " & v & vbCrLf & vbCrLf
  409.    n = 0.5
  410.    v = cFraction(n, p, q)
  411.    strDisplay = strDisplay & n & " is " & p & " / " & q & vbCrLf
  412.    strDisplay = strDisplay & "   value is " & v & vbCrLf & vbCrLf
  413.    n = 365.25
  414.    v = cFraction(n, p, q)
  415.    strDisplay = strDisplay & n & " is " & p & " / " & q & vbCrLf
  416.    strDisplay = strDisplay & "   value is " & v & vbCrLf & vbCrLf
  417.    n = 3.14
  418.    v = cFraction(n, p, q)
  419.    strDisplay = strDisplay & n & " is " & p & " / " & q & vbCrLf
  420.    strDisplay = strDisplay & "   value is " & v & vbCrLf & vbCrLf
  421.    n = 3.14159
  422.    v = cFraction(n, p, q)
  423.    strDisplay = strDisplay & n & " is " & p & " / " & q & vbCrLf
  424.    strDisplay = strDisplay & "   value is " & v & vbCrLf & vbCrLf
  425.    n = 3.14159265
  426.    v = cFraction(n, p, q)
  427.    strDisplay = strDisplay & n & " is " & p & " / " & q & vbCrLf
  428.    strDisplay = strDisplay & "   value is " & v & vbCrLf & vbCrLf
  429.    n = 0.9999999
  430.    v = cFraction(n, p, q)
  431.    strDisplay = strDisplay & n & " is " & p & " / " & q & vbCrLf
  432.    strDisplay = strDisplay & "   value is " & v
  433.    txt_Result = strDisplay
  434.    'time the function
  435.    TimerHandle = cTimerOpen()
  436.    TimerStartOk = cTimerStart(TimerHandle)
  437.    For i = 1 To Iteration
  438.       dblResult = cFraction(n, p, q)
  439.    Next i
  440.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  441.    TimerCloseOk = cTimerClose(TimerHandle)
  442. End Sub
  443. Private Sub TestBaseConversion()
  444.    Dim lngResult        As Long
  445.    Dim strResult        As String
  446.    Dim strDisplay       As String
  447.    Dim i                As Integer
  448.    Dim Str1             As String
  449.    lngResult = 0
  450.    strResult = ""
  451.    strDisplay = ""
  452.      
  453.    For i = 1 To 34
  454.       strDisplay = strDisplay & "Convert '1234567' base 10 to base " & i & " is " & cBaseConversion("1234567", 10, i) & vbCrLf
  455.    Next i
  456.    txt_Result = strDisplay
  457.    'time the function
  458.    TimerHandle = cTimerOpen()
  459.    TimerStartOk = cTimerStart(TimerHandle)
  460.    For i = 1 To Iteration
  461.       strResult = cBaseConversion("123456789", 10, 10)
  462.    Next i
  463.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  464.    TimerCloseOk = cTimerClose(TimerHandle)
  465. End Sub
  466. Private Sub TestCombination()
  467.    Dim dblResult        As Double
  468.    Dim strResult        As String
  469.    Dim strDisplay       As String
  470.    Dim i                As Integer
  471.    Dim Str1             As String
  472.    dblResult = 0
  473.    strResult = ""
  474.    strDisplay = ""
  475.      
  476.    For i = 0 To 10
  477.       strDisplay = strDisplay & "Combination C(42, " & i & ") is '" & cCombination(42, i) & "'" & vbCrLf
  478.    Next i
  479.    strDisplay = strDisplay & vbCrLf
  480.    For i = 42 To 32 Step -1
  481.       strDisplay = strDisplay & "Combination C(42, " & i & ") is '" & cCombination(42, i) & "'" & vbCrLf
  482.    Next i
  483.    txt_Result = strDisplay
  484.    'time the function
  485.    TimerHandle = cTimerOpen()
  486.    TimerStartOk = cTimerStart(TimerHandle)
  487.    For i = 1 To Iteration
  488.       dblResult = cCombination(42, 6)
  489.    Next i
  490.    mdiT2W.pnl_Timer = cTimerRead(TimerHandle)
  491.    TimerCloseOk = cTimerClose(TimerHandle)
  492. End Sub
  493.